package com.jt.www.remote;

import com.jt.www.domain.dto.*;
import com.jt.www.model.Insurancedata.*;
import com.jt.www.model.reps.GenericDataResponse;
import com.jt.www.model.reps.GenericListResponse;
import feign.Logger;
import feign.hystrix.FallbackFactory;
import io.swagger.annotations.ApiParam;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@FeignClient(value = "statistic-svc", url = "${remote.statistic_svc_url}",
        configuration = StatisticFeignConfig.class,
        fallbackFactory = StatisticClient.FeignClientFallbackFactory.class)
public interface StatisticClient {
    /**
     * 业务同比 新增投保企业数
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getNewInsureCorporation")
    GenericDataResponse<List<BusinessGrewVO>> getNewInsureCorporation(@RequestBody DataApiBean dataApiBean);

    /**
     * 业务同比 新增投保保费
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getNewInsurePrem")
    GenericDataResponse<List<BusinessGrewVO>> getNewInsurePrem(@RequestBody DataApiBean dataApiBean);

    /**
     * 业务同比 新增投保人数
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getNewInsurePeople")
    GenericDataResponse<List<BusinessGrewVO>> getNewInsurePeople(@RequestBody DataApiBean dataApiBean);

    /**
     * 业务同比 保费
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getNewPrem")
    GenericDataResponse<List<BusinessGrewVO>> getNewPrem(@RequestBody DataApiBean dataApiBean);

    /**
     * 业务同比 新增注册企业数
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getNewRegistered")
    GenericDataResponse<List<BusinessGrewVO>> getNewgetRegistered(@RequestBody DataApiBean dataApiBean);

    /**
     * 统保示范项目业务统计
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getUnfiedInsureProject")
    GenericDataResponse<List<UnfiedInsureProjectV0>> getUnfiedInsureProject(@RequestBody DataApiBean dataApiBean);

    /**
     * 统保附加险投保率统计
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getAdditionInsureRate")
    GenericDataResponse<List<AdditionInsureRateV0>> getAdditionInsureRate(@RequestBody DataApiBean dataApiBean);

    /**
     * 实责与安责同期投保情况明细表
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getSamePeriodInsure")
    GenericDataResponse<List<PeriodinsVO>> getSamePeriodInsure(@RequestBody DataApiBean dataApiBean);

    /**
     * 安责险统计表
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getSecurityInsurance")
    GenericDataResponse<List<SafeinsVO>> getSecurityInsurance(@RequestBody DataApiBean dataApiBean);

    /**
     * 年度实责转化安责情况表
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getAnnualStatistics")
    GenericDataResponse<List<ConverVO>> getAnnualStatistics(@RequestBody DataApiBean dataApiBean);

    /**
     * 云南专用投保
     *
     * @param dataApiBean
     * @return
     */
    @PostMapping("/api/v1/edu/getYunnanSpecial")
    GenericDataResponse<List<YunnanSpecialVO>> getYunnanSpecial(@RequestBody DataApiBean dataApiBean);

    /**
     * 统保示范项目
     *
     * @return
     */
    @PostMapping("/api/v1/edu/getUnitTotal")
    GenericDataResponse<List<Object>> getUnitTotal(@RequestBody DataApiBean dataApiBean);

    /**
     * 汇总表
     *
     * @return
     */
    @PostMapping("/api/v1/edu/getTotalStatus")
    GenericDataResponse<List<Object>> getTotalStatus(@RequestBody DataApiBean dataApiBean);

    /**
     * 区域统保
     *
     * @return
     */
    @PostMapping("/api/v1/edu/getPartTotal")
    GenericDataResponse<List<Object>> getPartTotal(@RequestBody DataApiBean dataApiBean);

    /**
     * 延伸业务
     *
     * @return
     */
    @PostMapping("/api/v1/edu/getExtend")
    GenericDataResponse<List<Object>> getExtend(@RequestBody DataApiBean dataApiBean);

    /**
     * 我学保
     *
     * @return
     */
    @PostMapping("/api/v1/edu/getWoXueBao")
    GenericDataResponse<List<Object>> getWoXueBao(@RequestBody DataApiBean dataApiBean);

    /**
     * 学平险
     *
     * @return
     */
    @PostMapping("/api/v1/edu/getXuePing")
    GenericDataResponse<List<Object>> getXuePing(@RequestBody DataApiBean dataApiBean);

    /**
     * 校车业务
     *
     * @return
     */
    @PostMapping("/api/v1/edu/getSchoolBus")
    GenericDataResponse<List<Object>> getSchoolBus(@RequestBody DataApiBean dataApiBean);

    /**
     * 安全咨询服务
     *
     * @return
     */
    @PostMapping("/api/v1/edu/getConsult")
    GenericDataResponse<List<Object>> getConsult(@RequestBody DataApiBean dataApiBean);

    /**
     * 630投保数据统计
     *
     * @param map
     * @return
     */
    @PostMapping("/api/v1/edu/getEdu630")
    Map getEdu630(@RequestBody Map map);

    /**
     * 每日实时投保数据统计
     *
     * @param map
     * @return
     */
    @PostMapping("/api/v1/edu/getEduDay")
    Map getEduDay(@RequestBody Map map);


    /**
     * 按天统计历史数据
     *
     * @param map
     * @return
     */
    @PostMapping("/api/v1/application/dayStatistic")
    Map dayStatistic(@RequestBody Map map);

    /**
     * 查询今天实时数据
     *
     * @param map
     * @return
     */
    @PostMapping("/api/v1/application/thisDayStatistic")
    Map thisDayStatistic(@RequestBody Map map);

    /**
     * 按小时统计昨天各小时数据
     *
     * @param map
     * @return
     */
    @PostMapping("/api/v1/application/hourStatistic")
    Map hourStatistic(@RequestBody Map map);

    /**
     * 按小时统计今天实时数据
     *
     * @param map
     * @return
     */
    @PostMapping("/api/v1/application/thisHourStatistic")
    Map thisHourStatistic(@RequestBody Map map);

    /**
     * 教育渠道汇总表
     *
     * @param inputDate
     * @return
     */
    @GetMapping(value = "/api/v1/edu/statistic/hzb")
    ResponseEntity<GenericListResponse<HzbDto>> hzbStatistic(@ApiParam(value = "查询日期", required = true) @RequestParam("inputDate") String inputDate,
                                                             @ApiParam(value = "分支机构编码", required = true) @RequestParam("branchCode") String branchCode) throws Exception;

    /**
     * 统保示范项目统计表
     *
     * @param inputDate
     * @return
     */
    @GetMapping(value = "/api/v1/edu/statistic/tbsfxm")
    ResponseEntity<GenericListResponse<TbsfxmDto>> tbsfxmStatistic(@ApiParam(value = "查询日期", required = true) @RequestParam("inputDate") String inputDate) throws Exception;

    /**
     * 延伸业务统计表
     *
     * @param inputDate
     * @return
     */
    @GetMapping(value = "/api/v1/edu/statistic/ysyw")
    ResponseEntity<GenericListResponse<YsywDto>> ysywStatistic(@ApiParam(value = "查询日期", required = true) @RequestParam("inputDate") String inputDate) throws Exception;

    /**
     * 区域统保业务统计表
     *
     * @param inputDate
     * @return
     */
    @GetMapping(value = "/api/v1/edu/statistic/qytb")
    ResponseEntity<GenericListResponse<QytbDto>> qytbStatistic(@ApiParam(value = "查询日期", required = true) @RequestParam("inputDate") String inputDate) throws Exception;

    /**
     * 我学保统计表
     *
     * @param inputDate
     * @return
     */
    @GetMapping(value = "/api/v1/edu/statistic/wxb")
    ResponseEntity<GenericListResponse<WxbDto>> wxbStatistic(@ApiParam(value = "查询日期", required = true) @RequestParam("inputDate") String inputDate) throws Exception;

    /**
     * 学平险统计表
     *
     * @param inputDate
     * @return
     */
    @GetMapping(value = "/api/v1/edu/statistic/xpx")
    ResponseEntity<GenericListResponse<XpxDto>> xpxStatistic(@ApiParam(value = "查询日期", required = true) @RequestParam("inputDate") String inputDate) throws Exception;


    @Component
    class FeignClientFallbackFactory implements FallbackFactory<StatisticClient> {

        public static final org.slf4j.Logger log = LoggerFactory.getLogger(FeignClientFallbackFactory.class);

        @Override
        public StatisticClient create(Throwable cause) {
            return new StatisticClient() {
                /**
                 * 业务同比 新增投保企业数
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<BusinessGrewVO>> getNewInsureCorporation(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 业务同比 新增投保保费
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<BusinessGrewVO>> getNewInsurePrem(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 业务同比 新增投保人数
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<BusinessGrewVO>> getNewInsurePeople(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 业务同比 保费
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<BusinessGrewVO>> getNewPrem(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 业务同比 新增注册企业数
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<BusinessGrewVO>> getNewgetRegistered(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 统保示范项目业务统计
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<UnfiedInsureProjectV0>> getUnfiedInsureProject(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 统保附加险投保率统计
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<AdditionInsureRateV0>> getAdditionInsureRate(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 实责与安责同期投保情况明细表
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<PeriodinsVO>> getSamePeriodInsure(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 安责险统计表
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<SafeinsVO>> getSecurityInsurance(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 年度实责转化安责情况表
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<ConverVO>> getAnnualStatistics(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 云南专用投保
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<YunnanSpecialVO>> getYunnanSpecial(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 统保示范项目
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<Object>> getUnitTotal(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 汇总表
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<Object>> getTotalStatus(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 区域统保
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<Object>> getPartTotal(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 延伸业务
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<Object>> getExtend(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 我学保
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<Object>> getWoXueBao(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 学平险
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<Object>> getXuePing(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 校车业务
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<Object>> getSchoolBus(DataApiBean dataApiBean) {
                    return null;
                }

                /**
                 * 安全咨询服务
                 *
                 * @param dataApiBean
                 * @return
                 */
                @Override
                public GenericDataResponse<List<Object>> getConsult(DataApiBean dataApiBean) {
                    return null;
                }

                @Override
                public Map getEdu630(Map map) {
                    return null;
                }

                @Override
                public Map getEduDay(Map map) {
                    return null;
                }

                @Override
                public Map dayStatistic(Map map) {
                    return null;
                }

                @Override
                public Map thisDayStatistic(Map map) {
                    return null;
                }

                @Override
                public Map hourStatistic(Map map) {
                    return null;
                }

                @Override
                public Map thisHourStatistic(Map map) {
                    return null;
                }

                @Override
                public ResponseEntity<GenericListResponse<HzbDto>> hzbStatistic(String inputDate, String branchCode) throws Exception {
                    log.error("远程调用教育渠道汇总表统计接口失败,fallback reason:", cause);
                    return null;
                }

                @Override
                public ResponseEntity<GenericListResponse<TbsfxmDto>> tbsfxmStatistic(String inputDate) throws Exception {
                    log.error("远程调用教育渠道统保示范项目统计接口失败,fallback reason:", cause);
                    return null;
                }

                @Override
                public ResponseEntity<GenericListResponse<YsywDto>> ysywStatistic(String inputDate) throws Exception {
                    log.error("远程调用教育渠道延伸业务统计接口失败,fallback reason:", cause);
                    return null;
                }

                @Override
                public ResponseEntity<GenericListResponse<QytbDto>> qytbStatistic(String inputDate) throws Exception {
                    log.error("远程调用教育渠道区域统保业务统计接口失败,fallback reason:", cause);
                    return null;
                }

                @Override
                public ResponseEntity<GenericListResponse<WxbDto>> wxbStatistic(String inputDate) throws Exception {
                    log.error("远程调用教育渠道我学保统计接口失败,fallback reason:", cause);
                    return null;
                }

                @Override
                public ResponseEntity<GenericListResponse<XpxDto>> xpxStatistic(String inputDate) throws Exception {
                    log.error("远程调用教育渠道学平险统计接口失败,fallback reason:", cause);
                    return null;
                }
            };
        }
    }

}

class StatisticFeignConfig {
    @Bean
    public Logger.Level logger() {
        return Logger.Level.FULL;
    }
}
